package br.com.andreikeda.utility.gestor.finance.storage.database.model;

/**
 * Created by LimaoGames on 22/01/2015.
 * contact me: andreikeda87@gmail.com
 */
public class Stock {

    private String code;
    private int total;
    private long companyId;

    public Stock(String code, int total, long companyId) {
        this.code = code;
        this.total = total;
        this.companyId = companyId;
    }

    public boolean diff(int qty) {
        int aux = total - qty;
        if (aux < 0)
            return false;
        total -= qty;
        return true;
    }

    public String getCode() {
        return code;
    }

    public long getCompanyId() {
        return companyId;
    }

    public int getTotal() {
        return total;
    }

    public boolean isCodeValid() {
        return code.length() < 16;
    }

    public void setTotal(int total) {
        this.total = total;
    }

    public void sum(int qty) {
        total += qty;
    }

}
